<script>
export default {
  onLaunch: function () {},
  onShow: function () {
    this.setEnv('pro')
    // this.setEnv('dev');

    console.log('[------- 系统信息 -------] :', uni.getSystemInfoSync())
  },
  created: function () {
    let path = this.$route.path
    // 单点供应模式（若页面刷新即退出该模式）
    if (path.includes('pages/singleMode')) {
      uni.setStorageSync('orderType', 'singleMode')
    } else {
      uni.removeStorageSync('orderType')
      if (uni.getStorageSync('indexAfterLogin') != 'singleMode') {
        uni.removeStorageSync('single_addressId')
      }
    }

    if (path.includes('bcwl')) {
      uni.setStorageSync('isSpecial', true)
      uni.redirectTo({
        // url: '/pages/index/index',
        url: '/pages/home/index',
      })
    } else {
      console.log('app.vue created 清除isSpecial缓存')
      uni.removeStorageSync('isSpecial')
    }
  },

  globalData: {
    BASE_URL: '',
    BASE_IMG_URL: '',

    shakeFlag: false,
    myLatelyAddress: null,
  },
  methods: {
    //设置开发环境
    setEnv(env) {
      this.globalData.env = env
      if (env == 'dev') {
        let baseUrl = 'http://120.24.54.28:8085/jeecg-boot/'
        this.globalData.BASE_URL = baseUrl
        this.globalData.BASE_IMG_URL = baseUrl + 'sys/common/static/'
      } else if (env == 'test') {
        this.globalData.BASE_URL = 'http://120.79.152.100:8085/jeecg-boot/'
        this.globalData.BASE_IMG_URL = 'http://120.79.152.100:8085/jeecg-boot/sys/common/static/'
      } else if (env == 'pro') {
        this.globalData.BASE_URL = 'https://admin.yongshantuan.cn/jeecg-boot/'
        this.globalData.BASE_IMG_URL = 'https://admin.yongshantuan.cn/jeecg-boot/sys/common/static/'
      }

      const { protocol } = location
      // const wsProtocol = protocol === 'http:' ? 'ws:' : 'wss:'
      const wsProtocol = 'ws:'
      this.globalData.WS_BASE_URL = `${wsProtocol}//119.23.235.14:8081/jeecg-boot`

      setTimeout(() => {
        if (location.href.includes('localhost')) {
          document.body.classList.add('dev') // 本地显示vconsole
        }
      }, 2000)
    },
  },
}
</script>

<style lang="scss">
/*每个页面公共css */
/* @import "@/uni.scss"; */

body {
  /* 防止微信浏览器将字体变小 */
  -webkit-text-size-adjust: 100% !important;
}
#__vconsole {
  display: none;
}
.dev ~ #__vconsole {
  display: block;
}

view,
radio,
textarea,
input {
  box-sizing: border-box;
}

view {
  font-family: 'Arial,sans-serif';
}

/* @font-face {
		font-family: '思源黑体';
		src: url("./static/font/SourceHanSansCN-Normal.otf");
	}

	@font-face {
		font-family: '思源宋体';
		src: url("./static/font/SourceHanSerifCN-Heavy.OTF");
	} */

/* 页面bg */
@media screen and (min-width: 600px) {
  uni-page-body {
    background-color: seagreen;
    background-image: url('./static/bg_green.jpg');
    background-repeat: repeat;
    background-position-x: center;
    background-position-y: center;
  }
}

.b {
  font-weight: 600;
  font-weight: bold;
}
.c {
  text-align: center;
}

.page_wrap,
.indexBig {
  max-width: 600px;
  margin: 0 auto;
  .commenMenu,
  .shopCarBottom,
  .shopCarBox,
  .settle_wrap {
    max-width: 600px;
    margin: 0 auto;
  }
}

/*每个页面公共css */
.commenButton {
  width: 100%;
  background-color: #ffa96a;
  color: #fff;
  font-size: 32rpx;
  line-height: 1.5;
  padding: 20rpx;
  border-radius: 200rpx;
  text-align: center;
}

.litterBox {
  padding: 0 40rpx;
  overflow: auto;
  margin-top: 10rpx;
}

.u-toast {
  /* width: 90% !important; */
  max-width: 100% !important;
  box-shadow: 0 0 5px #eee;
  border: 1px solid #eee;
}

@import 'uview-ui/index.scss';
</style>
